package com.example.sample.activity;

import android.os.Bundle;
import android.view.View;

import com.example.app.BaseActivity;
import com.example.sample.R;
import com.example.sample.logic.fsm.FSMEvtMsg;
import com.example.sample.logic.fsm.FSMEvtRestoreToNormal;
import com.example.sample.logic.fsm.TestFSMManager;

public class FSMActivity extends BaseActivity {

    private TestFSMManager fsm = new TestFSMManager();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fsm);

        findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fsm.fireEvent(new FSMEvtMsg("哈哈哈"));
            }
        });

        findViewById(R.id.sendX).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fsm.fireEvent(new FSMEvtMsg("xxx"));
            }
        });

        findViewById(R.id.restore).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fsm.fireEvent(new FSMEvtRestoreToNormal());
            }
        });

        // 启动状态机
        fsm.start();
    }
}
